$(function () {
    //======================
    //======设置查询条件========
    //======================
    //内部公司
    $("#wlycwsfckh_toolbar [name='gsId']").gsjgtree(1);
    //计划年份
    var yearSpinner = $("#wlycwsfckh_toolbar [name='year']").numberspinner({
        min: 2000,
        max: 2100,
        editable: true
    });
    //计划月份
    var monthSpinner = $("#wlycwsfckh_toolbar [name='month']").numberspinner({
        min: 1,
        max: 12,
        editable: true
    });


//======================
//========统计列表========
//======================
    var columns = [
        [
            {field: 'gsname', title: '园区', rowspan: 2, width: 100, align: 'center'},
            {field: 'khname', title: '客户', rowspan: 2, width: 100, align: 'center'},
            {field: 'qc', title: '期初', rowspan: 2, width: 100, align: 'right'},
            {title: '本期购入', colspan: 2, width: 100},
            {title: '本期发出', colspan: 1, width: 100},
            {field: 'qm', title: '期末', rowspan: 2, width: 100, align: 'right'}
        ],
        [
            {field: 'cgjs', title: '采购结算', width: 100, align: 'right'},
            {field: 'wljs', title: '物流结算', width: 100, align: 'right'},
            {field: 'xsjs', title: '销售结算', width: 100, align: 'right'}
        ]
    ];

    var grid = $('#wlycwsfckh_grid').datagrid({
        url: $.webPath() + '/report/wlycwsfckh/wlycwsfckhList',
        toolbar: "#wlycwsfckh_toolbar",
        pagination: true,
        rownumbers: true,
        singleSelect: true,
        collapsible: true,
        fit: true,
        fitColumns: true,
        pageNumber: 1,
        showFooter: true,
        queryParams: {
            year: $("#wlycwsfckh_toolbar [name='year']").val(),
            month: $("#wlycwsfckh_toolbar [name='month']").val()
        },
        onLoadSuccess: function () {
        },
        columns: columns
    });

    //搜索按钮
    $("#wlycwsfckh_toolbar [name='searchButton']").click(function () {
        $(grid).datagrid({
            queryParams: {
                year: $("#wlycwsfckh_toolbar [name='year']").val(),
                month: $("#wlycwsfckh_toolbar [name='month']").val(),
                gsId: $("#wlycwsfckh_toolbar [name='gsId']").val(),
                khMc: $("#wlycwsfckh_toolbar [name='khMc']").val()
            }});
    });


});


